Taxonomic analysis with percent
Preparation
Paths and libraries setting
# Load main packages, paths and custom functions
source("../../../source/main_packages.R")
source("../../../source/paths.R")
source("../../../source/functions.R")
# Load supplementary packages
packages <- c("RColorBrewer", "ggpubr", "cowplot")
invisible(lapply(packages, require, character.only = TRUE))Load phyloseq object after decontam
Parameters for plot
# new names for Genus
new_names_genus <- c("Wolbachia",
"Asaia",
"Legionella",
"Elizabethkingia",
"Chryseobacterium",
"Erwinia",
"Morganella",
"Pseudomonas",
"Delftia",
"Methylobacterium-Methylorubrum",
"Serratia",
"Coetzeea",
"NA"
)
# col for Genus
col_genus <- c("Wolbachia"="#FEB24C",
"Asaia"="#10E015",
"Legionella"="#DE3F23",
"Elizabethkingia"="#66A7ED",
"Chryseobacterium"="#F899FF",
"Erwinia"="#FFE352",
"Morganella"="#F5E4D3",
"Pseudomonas"="#DBF5F0",
"Delftia"="#C7C5B7",
"Methylobacterium-Methylorubrum"="blue",
"Serratia"="#B136F5",
"Coetzeea"="red",
"NA"="grey")
# param for plot
guide_italics <- guides(fill = guide_legend(label.theme = element_text(size = 10, face = "italic", colour = "Black", angle = 0)))
# labels
make.italic <- function(x) as.expression(lapply(x, function(y) bquote(italic(.(y)))))
labels = c("Wolbachia"=make.italic("Wolbachia"),
"Asaia"=make.italic("Asaia"),
"Legionella"=make.italic("Legionella"),
"Elizabethkingia"=make.italic("Elizabethkingia"),
"Chryseobacterium"=make.italic("Chryseobacterium"),
"Erwinia"=make.italic("Erwinia"),
"Morganella"=make.italic("Morganella"),
"Pseudomonas"=make.italic("Pseudomonas"),
"Delftia"=make.italic("Delftia"),
"Methylobacterium-Methylorubrum"=make.italic("Methylobacterium-Methylorubrum"),
"Serratia"=make.italic("Serratia"),
"Coetzeea"=make.italic("Coetzeea"),
"NA"
)Culex pipiens
Whole
df_plot <- df[df$Species.x=="Culex pipiens" & df$Organ=="Whole",] %>%
group_by(Species.x, Genus) %>%
summarise(read_sum = sum(Abundance))## `summarise()` regrouping output by 'Species.x' (override with `.groups` argument)
df_plot$percent <- (df_plot$read_sum/sum(df_plot$read_sum))*100
df_plot <- df_plot[with(df_plot, order(Species.x,-percent)),]
df_plot$Genus <- factor(df_plot$Genus, levels = unique(df_plot$Genus))
df_plot$Genus <- factor(df_plot$Genus, levels = new_names_genus)
df_plot <- droplevels(df_plot)
pipiens1 <- ggplot(df_plot, aes(x=Genus, y=percent, fill = Genus))+
geom_bar(position = "dodge", stat = "identity")+
scale_fill_manual(values = col_genus)+
theme_bw() +
theme(axis.text.x = element_text(angle = 45, vjust=1, hjust=1, size=12))+
ggtitle("") +
guide_italics+
theme(legend.title = element_text(size = 18), legend.position="bottom")+
theme(panel.spacing=unit(0,"lines"),
strip.background=element_rect(color="grey30", fill="grey90"),
panel.border=element_rect(color="grey90"),
plot.title=element_text(size=10),
axis.ticks.x=element_blank()) +
geom_text(aes(label=percent %>% round(1)),position=position_dodge(width=0.9), vjust=-0.25, size=4)+
scale_y_continuous(breaks=seq(0,105, by=10))+
scale_x_discrete(labels = labels)+
ylim(0,100)+
labs(title="All strains", x="Genus", y="Relative abundance (%)", subtitle= "Culex pipiens - Whole")+
theme(plot.tag.position = "topright",
plot.subtitle=element_text(size=10, face="italic", color="black"))## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
Whole - Bosc
df_plot <- df[df$Species.x=="Culex pipiens" & df$Organ=="Whole" & df$Strain=="Field - Bosc",] %>%
group_by(Strain, Genus) %>%
summarise(read_sum = sum(Abundance))## `summarise()` regrouping output by 'Strain' (override with `.groups` argument)
df_plot$percent <- (df_plot$read_sum/sum(df_plot$read_sum))*100
df_plot <- df_plot[with(df_plot, order(Strain,-percent)),]
df_plot$Genus <- factor(df_plot$Genus, levels = unique(df_plot$Genus))
df_plot$Genus <- factor(df_plot$Genus, levels = new_names_genus)
df_plot <- droplevels(df_plot)
pipiens2 <- ggplot(df_plot, aes(x=Genus, y=percent, fill = Genus))+
geom_bar(position = "dodge", stat = "identity")+
scale_fill_manual(values = col_genus)+
theme_bw() +
theme(axis.text.x = element_text(angle = 45, vjust=1, hjust=1, size=12))+
ggtitle("") +
guide_italics+
theme(legend.title = element_text(size = 18), legend.position="bottom")+
theme(panel.spacing=unit(0,"lines"),
strip.background=element_rect(color="grey30", fill="grey90"),
panel.border=element_rect(color="grey90"),
plot.title=element_text(size=10),
axis.ticks.x=element_blank()) +
geom_text(aes(label=percent %>% round(1)),position=position_dodge(width=0.9), vjust=-0.25, size=4)+
scale_y_continuous(breaks=seq(0,105, by=10))+
scale_x_discrete(labels = labels)+
ylim(0,100)+
labs(title="Field - Bosc", x="Genus", y="Relative abundance (%)", subtitle= "Culex pipiens - Whole")+
theme(plot.tag.position = "topright",
plot.subtitle=element_text(size=10, face="italic", color="black"))## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
Whole - Camping Europe
df_plot <- df[df$Species.x=="Culex pipiens" & df$Organ=="Whole" & df$Strain=="Field - Camping Europe",] %>%
group_by(Strain, Genus) %>%
summarise(read_sum = sum(Abundance))## `summarise()` regrouping output by 'Strain' (override with `.groups` argument)
df_plot$percent <- (df_plot$read_sum/sum(df_plot$read_sum))*100
df_plot <- df_plot[with(df_plot, order(Strain,-percent)),]
df_plot$Genus <- factor(df_plot$Genus, levels = unique(df_plot$Genus))
df_plot$Genus <- factor(df_plot$Genus, levels = new_names_genus)
df_plot <- droplevels(df_plot)
pipiens3 <- ggplot(df_plot, aes(x=Genus, y=percent, fill = Genus))+
geom_bar(position = "dodge", stat = "identity")+
scale_fill_manual(values = col_genus)+
theme_bw() +
theme(axis.text.x = element_text(angle = 45, vjust=1, hjust=1, size=12))+
ggtitle("") +
guide_italics+
theme(legend.title = element_text(size = 18), legend.position="bottom")+
theme(panel.spacing=unit(0,"lines"),
strip.background=element_rect(color="grey30", fill="grey90"),
panel.border=element_rect(color="grey90"),
plot.title=element_text(size=10),
axis.ticks.x=element_blank()) +
geom_text(aes(label=percent %>% round(1)),position=position_dodge(width=0.9), vjust=-0.25, size=4)+
scale_y_continuous(breaks=seq(0,105, by=10))+
scale_x_discrete(labels = labels)+
ylim(0,100)+
labs(title="Field - Camping Europe", x="Genus", y="Relative abundance (%)", subtitle= "Culex pipiens - Whole")+
theme(plot.tag.position = "topright",
plot.subtitle=element_text(size=10, face="italic", color="black"))## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
Whole - Lavar
df_plot <- df[df$Species.x=="Culex pipiens" & df$Organ=="Whole" & df$Strain=="Laboratory - Lavar",] %>%
group_by(Strain, Genus) %>%
summarise(read_sum = sum(Abundance))## `summarise()` regrouping output by 'Strain' (override with `.groups` argument)
df_plot$percent <- (df_plot$read_sum/sum(df_plot$read_sum))*100
df_plot <- df_plot[with(df_plot, order(Strain,-percent)),]
df_plot$Genus <- factor(df_plot$Genus, levels = unique(df_plot$Genus))
df_plot$Genus <- factor(df_plot$Genus, levels = new_names_genus)
df_plot <- droplevels(df_plot)
pipiens4 <- ggplot(df_plot, aes(x=Genus, y=percent, fill = Genus))+
geom_bar(position = "dodge", stat = "identity")+
scale_fill_manual(values = col_genus)+
theme_bw() +
theme(axis.text.x = element_text(angle = 45, vjust=1, hjust=1, size=12))+
ggtitle("") +
guide_italics+
theme(legend.title = element_text(size = 18), legend.position="bottom")+
theme(panel.spacing=unit(0,"lines"),
strip.background=element_rect(color="grey30", fill="grey90"),
panel.border=element_rect(color="grey90"),
plot.title=element_text(size=10),
axis.ticks.x=element_blank()) +
geom_text(aes(label=percent %>% round(1)),position=position_dodge(width=0.9), vjust=-0.25, size=4)+
scale_y_continuous(breaks=seq(0,105, by=10))+
scale_x_discrete(labels = labels)+
ylim(0,100)+
labs(title="Laboratory - Lavar", x="Genus", y="Relative abundance (%)", subtitle= "Culex pipiens - Whole")+
theme(plot.tag.position = "topright",
plot.subtitle=element_text(size=10, face="italic", color="black"))## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
Ovary
df_plot <- df[df$Species.x=="Culex pipiens" & df$Organ=="Ovary",] %>%
group_by(Species.x, Genus) %>%
summarise(read_sum = sum(Abundance))## `summarise()` regrouping output by 'Species.x' (override with `.groups` argument)
df_plot$percent <- (df_plot$read_sum/sum(df_plot$read_sum))*100
df_plot <- df_plot[with(df_plot, order(Species.x,-percent)),]
df_plot$Genus <- factor(df_plot$Genus, levels = unique(df_plot$Genus))
df_plot$Genus <- factor(df_plot$Genus, levels = new_names_genus)
df_plot <- droplevels(df_plot)
pipiens5 <- ggplot(df_plot, aes(x=Genus, y=percent, fill = Genus))+
geom_bar(position = "dodge", stat = "identity")+
scale_fill_manual(values = col_genus)+
theme_bw() +
theme(axis.text.x = element_text(angle = 45, vjust=1, hjust=1, size=12))+
ggtitle("") +
guide_italics+
theme(legend.title = element_text(size = 18), legend.position="bottom")+
theme(panel.spacing=unit(0,"lines"),
strip.background=element_rect(color="grey30", fill="grey90"),
panel.border=element_rect(color="grey90"),
plot.title=element_text(size=10),
axis.ticks.x=element_blank()) +
geom_text(aes(label=percent %>% round(1)),position=position_dodge(width=0.9), vjust=-0.25, size=4)+
scale_y_continuous(breaks=seq(0,105, by=10))+
scale_x_discrete(labels = labels)+
ylim(0,100)+
labs(title="All strains", x="Genus", y="Relative abundance (%)", subtitle= "Culex pipiens - Ovary")+
theme(plot.tag.position = "topright",
plot.subtitle=element_text(size=10, face="italic", color="black"))## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
Groups
Culex quinquefasciatus
Whole
df_plot <- df[df$Species.x=="Culex quinquefasciatus" & df$Organ=="Whole",] %>%
group_by(Species.x, Genus) %>%
summarise(read_sum = sum(Abundance))## `summarise()` regrouping output by 'Species.x' (override with `.groups` argument)
df_plot$percent <- (df_plot$read_sum/sum(df_plot$read_sum))*100
df_plot <- df_plot[with(df_plot, order(Species.x,-percent)),]
df_plot$Genus <- factor(df_plot$Genus, levels = unique(df_plot$Genus))
df_plot$Genus <- factor(df_plot$Genus, levels = new_names_genus)
df_plot <- droplevels(df_plot)
quinque1 <- ggplot(df_plot, aes(x=Genus, y=percent, fill = Genus))+
geom_bar(position = "dodge", stat = "identity")+
scale_fill_manual(values = col_genus)+
theme_bw() +
theme(axis.text.x = element_text(angle = 45, vjust=1, hjust=1, size=12))+
ggtitle("") +
guide_italics+
theme(legend.title = element_text(size = 18), legend.position="bottom")+
theme(panel.spacing=unit(0,"lines"),
strip.background=element_rect(color="grey30", fill="grey90"),
panel.border=element_rect(color="grey90"),
plot.title=element_text(size=10),
axis.ticks.x=element_blank()) +
geom_text(aes(label=percent %>% round(1)),position=position_dodge(width=0.9), vjust=-0.25, size=4)+
scale_y_continuous(breaks=seq(0,105, by=10))+
scale_x_discrete(labels = labels)+
ylim(0,100)+
labs(title="All strains", x="Genus", y="Relative abundance (%)", subtitle= "Culex quinquefasciatus - Whole")+
theme(plot.tag.position = "topright",
plot.subtitle=element_text(size=10, face="italic", color="black"))## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
Whole - Guadeloupe
df_plot <- df[df$Species.x=="Culex quinquefasciatus" & df$Organ=="Whole" & df$Strain=="Field - Guadeloupe",] %>%
group_by(Strain, Genus) %>%
summarise(read_sum = sum(Abundance))## `summarise()` regrouping output by 'Strain' (override with `.groups` argument)
df_plot$percent <- (df_plot$read_sum/sum(df_plot$read_sum))*100
df_plot <- df_plot[with(df_plot, order(Strain,-percent)),]
df_plot$Genus <- factor(df_plot$Genus, levels = unique(df_plot$Genus))
df_plot$Genus <- factor(df_plot$Genus, levels = new_names_genus)
df_plot <- droplevels(df_plot)
quinque2 <- ggplot(df_plot, aes(x=Genus, y=percent, fill = Genus))+
geom_bar(position = "dodge", stat = "identity")+
scale_fill_manual(values = col_genus)+
theme_bw() +
theme(axis.text.x = element_text(angle = 45, vjust=1, hjust=1, size=12))+
ggtitle("") +
guide_italics+
theme(legend.title = element_text(size = 18), legend.position="bottom")+
theme(panel.spacing=unit(0,"lines"),
strip.background=element_rect(color="grey30", fill="grey90"),
panel.border=element_rect(color="grey90"),
plot.title=element_text(size=10),
axis.ticks.x=element_blank()) +
geom_text(aes(label=percent %>% round(1)),position=position_dodge(width=0.9), vjust=-0.25, size=4)+
scale_y_continuous(breaks=seq(0,105, by=10))+
scale_x_discrete(labels = labels)+
ylim(0,100)+
labs(title="Field - Guadeloupe", x="Genus", y="Relative abundance (%)", subtitle= "Culex quinquefasciatus - Whole")+
theme(plot.tag.position = "topright",
plot.subtitle=element_text(size=10, face="italic", color="black"))## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
Whole - Slab TC
df_plot <- df[df$Species.x=="Culex quinquefasciatus" & df$Organ=="Whole" & df$Strain=="Laboratory - Slab TC (Wolbachia -)",] %>%
group_by(Strain, Genus) %>%
summarise(read_sum = sum(Abundance))## `summarise()` regrouping output by 'Strain' (override with `.groups` argument)
df_plot$percent <- (df_plot$read_sum/sum(df_plot$read_sum))*100
df_plot <- df_plot[with(df_plot, order(Strain,-percent)),]
df_plot$Genus <- factor(df_plot$Genus, levels = unique(df_plot$Genus))
df_plot$Genus <- factor(df_plot$Genus, levels = new_names_genus)
df_plot <- droplevels(df_plot)
quinque3 <- ggplot(df_plot, aes(x=Genus, y=percent, fill = Genus))+
geom_bar(position = "dodge", stat = "identity")+
scale_fill_manual(values = col_genus)+
theme_bw() +
theme(axis.text.x = element_text(angle = 45, vjust=1, hjust=1, size=12))+
ggtitle("") +
guide_italics+
theme(legend.title = element_text(size = 18), legend.position="bottom")+
theme(panel.spacing=unit(0,"lines"),
strip.background=element_rect(color="grey30", fill="grey90"),
panel.border=element_rect(color="grey90"),
plot.title=element_text(size=10),
axis.ticks.x=element_blank()) +
geom_text(aes(label=percent %>% round(1)),position=position_dodge(width=0.9), vjust=-0.25, size=4)+
scale_y_continuous(breaks=seq(0,105, by=10))+
scale_x_discrete(labels = labels)+
ylim(0,100)+
labs(title="Laboratory - Slab TC (Wolbachia -)", x="Genus", y="Relative abundance (%)", subtitle= "Culex quinquefasciatus - Whole")+
theme(plot.tag.position = "topright",
plot.subtitle=element_text(size=10, face="italic", color="black"))## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
Ovary
df_plot <- df[df$Species.x=="Culex quinquefasciatus" & df$Organ=="Ovary",] %>%
group_by(Species.x, Genus) %>%
summarise(read_sum = sum(Abundance))## `summarise()` regrouping output by 'Species.x' (override with `.groups` argument)
df_plot$percent <- (df_plot$read_sum/sum(df_plot$read_sum))*100
df_plot <- df_plot[with(df_plot, order(Species.x,-percent)),]
df_plot$Genus <- factor(df_plot$Genus, levels = unique(df_plot$Genus))
df_plot$Genus <- factor(df_plot$Genus, levels = new_names_genus)
df_plot <- droplevels(df_plot)
quinque4 <- ggplot(df_plot, aes(x=Genus, y=percent, fill = Genus))+
geom_bar(position = "dodge", stat = "identity")+
scale_fill_manual(values = col_genus)+
theme_bw() +
theme(axis.text.x = element_text(angle = 45, vjust=1, hjust=1, size=12))+
ggtitle("") +
guide_italics+
theme(legend.title = element_text(size = 18), legend.position="bottom")+
theme(panel.spacing=unit(0,"lines"),
strip.background=element_rect(color="grey30", fill="grey90"),
panel.border=element_rect(color="grey90"),
plot.title=element_text(size=10),
axis.ticks.x=element_blank()) +
geom_text(aes(label=percent %>% round(1)),position=position_dodge(width=0.9), vjust=-0.25, size=4)+
scale_y_continuous(breaks=seq(0,105, by=10))+
scale_x_discrete(labels = labels)+
ylim(0,100)+
labs(title="All strains", x="Genus", y="Relative abundance (%)", subtitle= "Culex quinquefasciatus - Ovary")+
theme(plot.tag.position = "topright",
plot.subtitle=element_text(size=10, face="italic", color="black"))## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
Aedes aegyti
Whole
df_plot <- df[df$Species.x=="Aedes aegypti" & df$Organ=="Whole",] %>%
group_by(Species.x, Genus) %>%
summarise(read_sum = sum(Abundance))## `summarise()` regrouping output by 'Species.x' (override with `.groups` argument)
df_plot$percent <- (df_plot$read_sum/sum(df_plot$read_sum))*100
df_plot <- df_plot[with(df_plot, order(Species.x,-percent)),]
df_plot$Genus <- factor(df_plot$Genus, levels = unique(df_plot$Genus))
df_plot$Genus <- factor(df_plot$Genus, levels = new_names_genus)
df_plot <- droplevels(df_plot)
aedes1 <- ggplot(df_plot, aes(x=Genus, y=percent, fill = Genus))+
geom_bar(position = "dodge", stat = "identity")+
scale_fill_manual(values = col_genus)+
theme_bw() +
theme(axis.text.x = element_text(angle = 45, vjust=1, hjust=1, size=12))+
ggtitle("") +
guide_italics+
theme(legend.title = element_text(size = 18), legend.position="bottom")+
theme(panel.spacing=unit(0,"lines"),
strip.background=element_rect(color="grey30", fill="grey90"),
panel.border=element_rect(color="grey90"),
plot.title=element_text(size=10),
axis.ticks.x=element_blank()) +
geom_text(aes(label=percent %>% round(1)),position=position_dodge(width=0.9), vjust=-0.25, size=4)+
scale_y_continuous(breaks=seq(0,105, by=10))+
scale_x_discrete(labels = labels)+
ylim(0,100)+
labs(title="All strains", x="Genus", y="Relative abundance (%)", subtitle= "Aedes aegytpi - Whole")+
theme(plot.tag.position = "topright",
plot.subtitle=element_text(size=10, face="italic", color="black"))## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
Ovary
df_plot <- df[df$Species.x=="Aedes aegypti" & df$Organ=="Ovary",] %>%
group_by(Species.x, Genus) %>%
summarise(read_sum = sum(Abundance))## `summarise()` regrouping output by 'Species.x' (override with `.groups` argument)
df_plot$percent <- (df_plot$read_sum/sum(df_plot$read_sum))*100
df_plot <- df_plot[with(df_plot, order(Species.x,-percent)),]
df_plot$Genus <- factor(df_plot$Genus, levels = unique(df_plot$Genus))
df_plot$Genus <- factor(df_plot$Genus, levels = new_names_genus)
df_plot <- droplevels(df_plot)
aedes2 <- ggplot(df_plot, aes(x=Genus, y=percent, fill = Genus))+
geom_bar(position = "dodge", stat = "identity")+
scale_fill_manual(values = col_genus)+
theme_bw() +
theme(axis.text.x = element_text(angle = 45, vjust=1, hjust=1, size=12))+
ggtitle("") +
guide_italics+
theme(legend.title = element_text(size = 18), legend.position="bottom")+
theme(panel.spacing=unit(0,"lines"),
strip.background=element_rect(color="grey30", fill="grey90"),
panel.border=element_rect(color="grey90"),
plot.title=element_text(size=10),
axis.ticks.x=element_blank()) +
geom_text(aes(label=percent %>% round(1)),position=position_dodge(width=0.9), vjust=-0.25, size=4)+
scale_y_continuous(breaks=seq(0,105, by=10))+
scale_x_discrete(labels = labels)+
ylim(0,100)+
labs(title="All strains", x="Genus", y="Relative abundance (%)", subtitle= "Aedes aegytpi - Ovary")+
theme(plot.tag.position = "topright",
plot.subtitle=element_text(size=10, face="italic", color="black"))## Scale for 'y' is already present. Adding another scale for 'y', which will
## replace the existing scale.
Plot with all
All
p_global <- plot_grid(pipiens1+ theme(legend.position="none"),
pipiens2+ theme(legend.position="none"),
pipiens3+ theme(legend.position="none"),
pipiens4+ theme(legend.position="none"),
pipiens5+ theme(legend.position="none", plot.margin = unit(c(0.17,1,1.2,0), "cm")),
quinque1+ theme(legend.position="none"),
quinque2+ theme(legend.position="none"),
quinque3+ theme(legend.position="none"),
quinque4+ theme(legend.position="none", plot.margin = unit(c(0.17,1,1.2,0), "cm")),
plot.new(),
aedes1+ theme(legend.position="none"),
#aedes2+ theme(legend.position="none", plot.margin = unit(c(0.17,1,1.2,0), "cm")),
plot.new(),
plot.new(),
plot.new(),
nrow=3,
ncol=5
)